import { APP_SET_SYSINFO } from "../mutation-types";
import { axios } from "@/request";

export default {
  state: {
    // public路径
    publicPath: process.env.BASE_URL, // 公共路径
    sysInfo: {
      // 系统信息
      version: {}
    },
    defaultSettings: {
      theme: "dark", // theme for nav menu
      primaryColor: "#F5222D", // primary color of ant design
      layout: "Default", // nav menu position: `default` or `Bluetech`
      contentWidth: "Fluid", // layout of content: `Fluid` or `Fixed`, only works when layout is topmenu
      fixedHeader: false, // sticky header
      fixSiderbar: false, // sticky siderbar
      colorWeak: false,
      menu: {
        locale: true
      },
      title: "Ant Design Pro",
      pwa: false,
      iconfontUrl: "",
      production: process.env.NODE_ENV === "production" && process.env.VUE_APP_PREVIEW !== "true"
    }
  },
  mutations: {
    [APP_SET_SYSINFO](state, value) {
      state.sysInfo = value;
    }
  },
  actions: {
    async setSysInfo({ commit }) {
      let res = await axios.get("/base/findNewWlVersionAndSysInfo");
      !res.code && commit(APP_SET_SYSINFO, res.data);
      return res;
    }
  }
};
